<?php

	include ('../Config/conn.php'); 
	include ('../Model/wishlist_item.class.php'); 
	
	$itensWishlist = array();
	$contador = 0;

	$cdWishlist = $_SESSION['cd_wishlist'];	
	
	$result = $db->query("SELECT wi.cd_wishlist,
								 i.cd_item,
								 i.nm_item,
								 p.ds_plataforma as nm_plataforma,
								 wi.cd_plataforma
							FROM wishlist_item wi
							INNER JOIN item i on i.cd_item = wi.cd_item
							INNER JOIN plataforma p on p.cd_plataforma = wi.cd_plataforma
							WHERE wi.cd_wishlist = $cdWishlist",
							PDO::FETCH_ASSOC);
	
	if ($result->rowCount() > 0) {
		
		while($item = $result->fetch()){

			$itemWishlist = new Wishlist_Item_Cadastrado($item);
			
			$itensWishlist[$contador] = $itemWishlist;
			
			$contador = $contador + 1;
		}
		
		$result->closeCursor();	
	} 
	
	include ('../Config/destruct.php'); 
?>